from time import ctime
import time
import threading
import _thread


def test1():
    for i in range(3):
        print("this is test1 {}".format(ctime()))
        time.sleep(1)


def test2():
    for i in range(3):
        print("this is test2 {0}".format(ctime()))
        time.sleep(1)


def test_threads():
    print()
    threads = []
    t1 = threading.Thread(target=test1)
    threads.append(t1)
    t2 = threading.Thread(target=test2)
    threads.append(t2)

    for t in threads:
        t.setDaemon(True)
        t.start()
    t.join()
    print("done {}".format(ctime()))


def test_threads2():
    print()
    threads = []
    t1 = threading.Thread(target=test1)
    threads.append(t1)
    t2 = threading.Thread(target=test2)
    threads.append(t2)

    for t in threads:
        t.setDaemon(True)
        t.start()
    for t in threads:
        t.setDaemon(True)
        t.join()
    print("done {}".format(ctime()))